package com.xijing.service;

import java.util.HashMap;
import java.util.Map;

import com.xijing.dao.AdminDAO;
import com.xijing.model.*;

public class LoginService {
	
	private AdminDAO adminDAO = new AdminDAO();

	public Map<String, Object> login(SYS_User adminDTO) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		
		SYS_User dbAdm = adminDAO.getAdmin(adminDTO.getSU_LoginName(),adminDTO.getSU_Password());
		if(dbAdm == null) {
			resultMap.put("succ", false);
			resultMap.put("msg", "当前用户不存在");
		} else if(!dbAdm.getSU_Password().equalsIgnoreCase(adminDTO.getSU_Password())) {
			resultMap.put("succ", false);
			resultMap.put("msg", "用户名密码错误");
		} else if(dbAdm.getSU_State() == 3) {
			resultMap.put("succ", false);
			resultMap.put("msg", "账户被锁定");
		} else {
			resultMap.put("succ", true);
		}
		
		return resultMap;
	}
}
